﻿/*********************************************************************************/
/**    Sims3Pack Readme Generator                                               **/
/**    Copyright (C) 2012  Anja Knackstedt                                      **/
/**                                                                             **/
/**    This program is free software: you can redistribute it and/or modify     **/
/**    it under the terms of the GNU General Public License as published by     **/
/**    the Free Software Foundation, either version 3 of the License, or        **/
/**    (at your option) any later version.                                      **/
/**                                                                             **/
/**    This program is distributed in the hope that it will be useful,          **/
/**    but WITHOUT ANY WARRANTY; without even the implied warranty of           **/
/**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            **/
/**    GNU General Public License for more details.                             **/
/**                                                                             **/
/**    You should have received a copy of the GNU General Public License        **/
/**    along with this program.  If not, see <http://www.gnu.org/licenses/>.    **/
/**                                                                             **/
/*********************************************************************************/




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;

namespace Sims3PackReadmeGenerator.Sims3PackReader
{
    class ReferenceResolver
    {
        #region fields

        //expansions, stuffpacks, storeitems
        private Dictionary<string, Dependency> _dictDependencies = new Dictionary<string,Dependency>();

        //bad cc guids
        private Dictionary<string, BadCC> _dictBadCC = new Dictionary<string,BadCC>();

        //known package guids
        private Dictionary<string, KnownPackage> _dictKnownPackages = new Dictionary<string,KnownPackage>();


        private Dictionary<string, Reference> _dictTraits   = new Dictionary<string,Reference>();
        private Dictionary<string, Reference> _dictAge      = new Dictionary<string,Reference>();
        private Dictionary<string, Reference> _dictSpecies  = new Dictionary<string,Reference>();

        private Dictionary<string, Reference> _dictGender           = new Dictionary<string,Reference>();
        private Dictionary<string, Reference> _dictFavColor         = new Dictionary<string,Reference>();
        private Dictionary<string, Reference> _dictFavMusic         = new Dictionary<string,Reference>();
        private Dictionary<string, Reference> _dictFavFood          = new Dictionary<string,Reference>();
        private Dictionary<string, Reference> _dictLotType          = new Dictionary<string,Reference>();
        private Dictionary<string, Reference> _dictLotResSubType    = new Dictionary<string,Reference>();
        private Dictionary<string, Reference> _dictLotComSubType    = new Dictionary<string,Reference>();

        private Dictionary<string, Reference> _dictMatCategories    = new Dictionary<string,Reference>();

        #endregion

        #region constructor

        public ReferenceResolver()
        {
            readAddonDependencies();

            if (Properties.Settings.Default.UseS3SBrowserData && Properties.Settings.Default.S3SBrowserPath != "")
            {
                readStoreDependencies();
            }

            readBadCCInformation();
            readKnownPackageInformation();

            readGameRefrereces();
        }

        #endregion

        #region methods

        public bool containsDependencyGuid(string guid)
        {
            return _dictDependencies.ContainsKey(guid);
        }

        public Dependency getDependency(string guid)
        {
            if (_dictDependencies.ContainsKey(guid))
            {
                return _dictDependencies[guid];
            }
            else
            {
                return null;
            }
        }

        public bool containsBadCCGuid(string guid)
        {
            return _dictBadCC.ContainsKey(guid);
        }

        public BadCC getBadCC(string guid)
        {
            if (_dictBadCC.ContainsKey(guid))
            {
                return _dictBadCC[guid];
            }
            else
            {
                return null;
            }
        }

        public bool containsKnownPackageGuid(string guid)
        {
            return _dictKnownPackages.ContainsKey(guid);
        }

        public KnownPackage getKnownPackage(string guid)
        {
            if (_dictKnownPackages.ContainsKey(guid))
            {
                return _dictKnownPackages[guid];
            }
            else
            {
                return null;
            }
        }

        #region resolve methods

        public string resolveTrait(string traitId, Languages lang)
        {
            if (_dictTraits.ContainsKey(traitId))
            {
                if (lang == Languages.de)
                    return _dictTraits[traitId].NameDE;
                else
                    return _dictTraits[traitId].NameEN;
            }
            else
            {
                return traitId;               
            }
        }

        public string resolveAge(string id, Languages lang)
        {
            if (_dictAge.ContainsKey(id))
            {
                if (lang == Languages.de)
                    return _dictAge[id].NameDE;
                else
                    return _dictAge[id].NameEN;
            }
            else
            {
                return id;
            }
        }

        public string resolveSpecies(string id, Languages lang)
        {
            if (_dictSpecies.ContainsKey(id))
            {
                if (lang == Languages.de)
                    return _dictSpecies[id].NameDE;
                else
                    return _dictSpecies[id].NameEN;
            }
            else
            {
                return "Sim";
            }
        }

        public string resolveSpeciesAndGetSimType(string id, Languages lang, out SimTypes type)
        {
            type = SimTypes.sim;
            switch (id)
            {
                case "0x00000200":
                    type = SimTypes.horse;
                    break;
                case "0x00000300":
                    type = SimTypes.cat;
                    break;
                case "0x00000400":
                    type = SimTypes.dogbig;
                    break;
                case "0x00000500":
                    type = SimTypes.dogsmall;
                    break;
                default:
                    type = SimTypes.sim;
                    break;
            }
            return resolveSpecies(id, lang);
        }

        public string resolveGender(string id, Languages lang)
        {
            if (_dictGender.ContainsKey(id))
            {
                if (lang == Languages.de)
                    return _dictGender[id].NameDE;
                else
                    return _dictGender[id].NameEN;
            }
            else
            {
                return id;
            }
        }

        public string resolveFavColor(string id, Languages lang)
        {
            if (_dictFavColor.ContainsKey(id))
            {
                if (lang == Languages.de)
                    return _dictFavColor[id].NameDE;
                else
                    return _dictFavColor[id].NameEN;
            }
            else
            {
                return id;
            }
        }

        public string resolveFavMusic(string id, Languages lang)
        {
            if (_dictFavMusic.ContainsKey(id))
            {
                if (lang == Languages.de)
                    return _dictFavMusic[id].NameDE;
                else
                    return _dictFavMusic[id].NameEN;
            }
            else
            {
                return id;
            }
        }

        public string resolveFavFood(string id, Languages lang)
        {
            if (_dictFavFood.ContainsKey(id))
            {
                if (lang == Languages.de)
                    return _dictFavFood[id].NameDE;
                else
                    return _dictFavFood[id].NameEN;
            }
            else
            {
                return id;
            }
        }

        public string resolveLotComSubType(string id, Languages lang)
        {
            if (_dictLotComSubType.ContainsKey(id))
            {
                if (lang == Languages.de)
                    return _dictLotComSubType[id].NameDE;
                else
                    return _dictLotComSubType[id].NameEN;
            }
            else
            {
                return id;
            }
        }

        public string resolveLotType(string id, Languages lang)
        {
            if (_dictLotType.ContainsKey(id))
            {
                if (lang == Languages.de)
                    return _dictLotType[id].NameDE;
                else
                    return _dictLotType[id].NameEN;
            }
            else
            {
                return id;
            }
        }

        public string resolveLotResSubType(string id, Languages lang)
        {
            if (_dictLotResSubType.ContainsKey(id))
            {
                if (lang == Languages.de)
                    return _dictLotResSubType[id].NameDE;
                else
                    return _dictLotResSubType[id].NameEN;
            }
            else
            {
                return id;
            }
        }

        public string resolveMatCategory(string id, Languages lang)
        {
            if (_dictMatCategories.ContainsKey(id))
            {
                if (lang == Languages.de)
                    return _dictMatCategories[id].NameDE;
                else
                    return _dictMatCategories[id].NameEN;
            }
            else
            {
                return id;
            }
        }

        /// <summary>
        /// get life stages and gender from the age and gender flags
        /// uses mask & flagsValue
        /// </summary>
        /// <param name="flags"></param>
        /// <param name="lang"></param>
        /// <param name="gender"></param>
        /// <param name="age"></param>
        public static void resolveAgeGenderFlags(string flags, Languages lang, out string gender, out string age)
        {
            int flagvalue = Convert.ToInt32(flags, 16);

            gender = "";
            age = "";

            if (lang == Languages.de)
            {
                if ((flagvalue & 0x00000001) == 0x00000001)
                    age += "Baby, ";
                if ((flagvalue & 0x00000002) == 0x00000002)
                    age += "Kleinkind, ";
                if ((flagvalue & 0x00000004) == 0x00000004)
                    age += "Kind, ";
                if ((flagvalue & 0x00000008) == 0x00000008)
                    age += "Teenager, ";
                if ((flagvalue & 0x00000010) == 0x00000010)
                    age += "Junger Erwachsener, ";
                if ((flagvalue & 0x00000020) == 0x00000020)
                    age += "Erwachsener, ";
                if ((flagvalue & 0x00000040) == 0x00000040)
                    age += "Senior, ";

                if ((flagvalue & 0x00001000) == 0x00001000)
                    gender += "Männlich, ";
                if ((flagvalue & 0x00002000) == 0x00002000)
                    gender += "Weiblich, ";
            }
            else
            {
                if ((flagvalue & 0x00000001) == 0x00000001)
                    age += "Baby, ";
                if ((flagvalue & 0x00000002) == 0x00000002)
                    age += "Toddler, ";
                if ((flagvalue & 0x00000004) == 0x00000004)
                    age += "Child, ";
                if ((flagvalue & 0x00000008) == 0x00000008)
                    age += "Teen, ";
                if ((flagvalue & 0x00000010) == 0x00000010)
                    age += "Young Adult, ";
                if ((flagvalue & 0x00000020) == 0x00000020)
                    age += "Adult, ";
                if ((flagvalue & 0x00000040) == 0x00000040)
                    age += "Elder, ";

                if ((flagvalue & 0x00001000) == 0x00001000)
                    gender += "Male, ";
                if ((flagvalue & 0x00002000) == 0x00002000)
                    gender += "Female, ";
            }

            //remove last comma and space
            if (age.Length > 2)
            {
                age = age.Substring(0, age.Length - 2);
            }
            if (gender.Length > 2)
            {
                gender = gender.Substring(0, gender.Length - 2);
            }


        }

        #endregion

        #region readDependencies

        /// <summary>
        /// reads info from addon xml
        /// </summary>
        private void readAddonDependencies()
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(FilePaths.addonXmlPath);

                XmlNode root = xmlDocument.DocumentElement;

                foreach (XmlNode dependency in root.ChildNodes)
                {
                    // read info from every node and at info to dictionary
                    if (dependency.Name == xmlStringValues.nodeDependency)
                    {
                        Dependency addonDependency = new Dependency();
                        foreach (XmlNode dependencyChild in dependency.ChildNodes)
                        {
                            switch (dependencyChild.Name)
                            {
                                case xmlStringValues.nodeDependencyGuid:
                                    addonDependency.Guid = dependencyChild.InnerText;
                                    break;
                                case xmlStringValues.nodeDependencyType:
                                    addonDependency.DependencyType = toDependencyType(dependencyChild.InnerText);
                                    break;
                                case xmlStringValues.nodeDependencyNameDE:
                                    addonDependency.NameDE = dependencyChild.InnerText;
                                    break;
                                case xmlStringValues.nodeDependencyNameEN:
                                    addonDependency.NameEN = dependencyChild.InnerText;
                                    break;
                                default:
                                    break;
                            }
                        }
                        if (_dictDependencies.ContainsKey(addonDependency.Guid) == false)
                        {
                            _dictDependencies.Add(addonDependency.Guid, addonDependency);
                        }
                    }
                }
            }
            catch(Exception)
            {
                throw;
            }
        }    

        /// <summary>
        /// reads store dependencies
        /// </summary>
        public void readStoreDependencies()
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(Properties.Settings.Default.S3SBrowserPath);

                XmlNode root = xmlDocument.DocumentElement;

                foreach (XmlNode storeDataNode in root.ChildNodes)
                {                    
                    if (storeDataNode.Name == xmlStringValues.nodeStoreItem)
                    {
                        Dependency storeDependency = new Dependency();
                        storeDependency.DependencyType = DependencyTypes.store;

                        foreach (XmlNode storeItemChild in storeDataNode.ChildNodes)
                        {

                            if (storeItemChild.Name == xmlStringValues.nodeStorePackageFileName)
                            {
                                storeDependency.Guid = storeItemChild.InnerText;
                            }
                            else if (storeItemChild.Name == xmlStringValues.nodeStoreItemNameGerman)
                            {
                                storeDependency.NameDE = storeItemChild.InnerText;
                            }
                            else if (storeItemChild.Name == xmlStringValues.nodeStoreItemName)
                            {
                                storeDependency.NameEN = storeItemChild.InnerText;
                            }

                        }
                        if (_dictDependencies.ContainsKey(storeDependency.Guid) == false)
                        {
                            _dictDependencies.Add(storeDependency.Guid, storeDependency);
                        }
                    }
                }
            }
            catch(Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// gets dependency type from string
        /// </summary>
        /// <param name="textType"></param>
        /// <returns></returns>
        private DependencyTypes toDependencyType(string textType)
        {
            DependencyTypes type = DependencyTypes.unknown;

            switch (textType)
            {
                case xmlStringValues.nodeDependencyTypeValExp:
                    type = DependencyTypes.expansion;
                    break;
                case xmlStringValues.nodeDependencyTypeValStuff:
                    type = DependencyTypes.stuffpack;
                    break;
                case xmlStringValues.nodeDependencyTypeValStore:
                    type = DependencyTypes.store;
                    break;
                default:
                    break;
            }

            return type;
        }       

        #endregion

        #region readPackageInfo

        /// <summary>
        /// read info from badcc.xml
        /// </summary>
        public void readBadCCInformation()
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(FilePaths.badCCXmlDataPath);

                XmlNode root = xmlDocument.DocumentElement;

                foreach (XmlNode badccitem in root.ChildNodes)
                {                   
                    if (badccitem.Name == xmlStringValues.nodeBadCCItem)
                    {
                        BadCC badCC = new BadCC();
                        foreach (XmlNode badccItemChild in badccitem.ChildNodes)
                        {
                            switch (badccItemChild.Name)
                            {
                                case xmlStringValues.nodeBadCCPackageId:
                                    badCC.Guid = badccItemChild.InnerText;
                                    break;
                                case xmlStringValues.nodeBadCCName:
                                    badCC.Name = badccItemChild.InnerText;
                                    break;
                                case xmlStringValues.nodeBadCCCategory:
                                    badCC.Type = toBadCCTyp(badccItemChild.InnerText);
                                    break;                                
                                default:
                                    break;
                            }
                        }
                        if (_dictBadCC.ContainsKey(badCC.Guid) == false)
                        {
                            _dictBadCC.Add(badCC.Guid, badCC);
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// gets a bad cc type from a string value
        /// </summary>
        /// <param name="textType"></param>
        /// <returns></returns>
        private BadCCTypes toBadCCTyp(string textType)
        {
            BadCCTypes badCCType = BadCCTypes.other;

            switch (textType)
            {
                case xmlStringValues.badCCErrorCatIdCrash:
                    badCCType = BadCCTypes.crash;
                    break;
                case xmlStringValues.badCCErrorCatIdTxtcError:
                    badCCType = BadCCTypes.txtcerror;
                    break;
                case xmlStringValues.badCCErrorCatIdTextureErr:
                    badCCType = BadCCTypes.textureerror;
                    break;
                default:
                    break;
            }

            return badCCType;
        }

        /// <summary>
        /// read info about known packages from packages.xml
        /// </summary>
        public void readKnownPackageInformation()
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(FilePaths.knownCCXmlDataPath);

                XmlNode root = xmlDocument.DocumentElement;

                foreach (XmlNode package in root.ChildNodes)
                {
                    
                    if (package.Name == xmlStringValues.nodeKnownCCItem)
                    {
                        KnownPackage knownPackage = new KnownPackage();
                        foreach (XmlNode knownPackageChild in package.ChildNodes)
                        {
                            switch (knownPackageChild.Name)
                            {
                                case xmlStringValues.nodeKnownCCPackageId:
                                    knownPackage.Guid = knownPackageChild.InnerText;
                                    break;
                                case xmlStringValues.nodeKnownCCNameDe:
                                    knownPackage.ItemNameDE = knownPackageChild.InnerText;
                                    break;
                                case xmlStringValues.nodeKnownCCNameEn:
                                    knownPackage.ItemNameEN = knownPackageChild.InnerText;
                                    break;
                                case xmlStringValues.nodeKnownCCCreator:
                                    knownPackage.Creator = knownPackageChild.InnerText;
                                    break;
                                case xmlStringValues.nodeKnownCCHomepage:
                                    knownPackage.Homepage = knownPackageChild.InnerText;
                                    break;
                                default:
                                    break;
                            }
                        }
                        if (_dictKnownPackages.ContainsKey(knownPackage.Guid) == false)
                        {
                            _dictKnownPackages.Add(knownPackage.Guid, knownPackage);
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }

        #endregion

        #region readGameRefrereces

        /// <summary>
        /// read info from gameref.xml
        /// </summary>
        private void readGameRefrereces()
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(FilePaths.gamerefXmlPath);

                XmlNode root = xmlDocument.DocumentElement;

                foreach (XmlNode refNode in root.ChildNodes)
                {                    
                    if (refNode.Name == xmlStringValues.nodeGamerefTraits)
                    {
                        readReferenceToDictionary(refNode, _dictTraits);
                    }
                    else if (refNode.Name == xmlStringValues.nodeGamerefSpeciesTypes)
                    {
                        readReferenceToDictionary(refNode, _dictSpecies);
                    }
                    else if (refNode.Name == xmlStringValues.nodeGamerefMusic)
                    {
                        readReferenceToDictionary(refNode, _dictFavMusic);
                    }
                    else if (refNode.Name == xmlStringValues.nodeGamerefColor)
                    {
                        readReferenceToDictionary(refNode, _dictFavColor);
                    }
                    else if (refNode.Name == xmlStringValues.nodeGamerefFood)
                    {
                        readReferenceToDictionary(refNode, _dictFavFood);
                    }
                    else if (refNode.Name == xmlStringValues.nodeGamerefLifestages)
                    {
                        readReferenceToDictionary(refNode, _dictAge);
                    }
                    else if (refNode.Name == xmlStringValues.nodeGamerefGenders)
                    {
                        readReferenceToDictionary(refNode, _dictGender);
                    }
                    else if (refNode.Name == xmlStringValues.nodeGamerefLottypes)
                    {
                        readReferenceToDictionary(refNode, _dictLotType);
                    }
                    else if (refNode.Name == xmlStringValues.nodeGamerefLotComSubtypes)
                    {
                        readReferenceToDictionary(refNode, _dictLotComSubType);
                    }
                    else if (refNode.Name == xmlStringValues.nodeGamerefLotResSubtypes)
                    {
                        readReferenceToDictionary(refNode, _dictLotResSubType);
                    }
                    else if (refNode.Name == xmlStringValues.nodeGamerefMatcategories)
                    {
                        readReferenceToDictionary(refNode, _dictMatCategories);
                    }   
                   
                }
            }
            catch(Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// reads a reference and adds a new refrence object to the given dictionary
        /// </summary>
        /// <param name="root"></param>
        /// <param name="dictionary"></param>
        private void readReferenceToDictionary(XmlNode root, Dictionary<string, Reference> dictionary)
        {
            foreach (XmlNode category in root.ChildNodes)
            {
                if (category.NodeType != XmlNodeType.Comment)
                {
                    Reference reference = new Reference();

                    foreach (XmlNode child in category.ChildNodes)
                    {
                        switch (child.Name)
                        {
                            case xmlStringValues.nodeReferenceId:
                                reference.ID = child.InnerText;
                                break;
                            case xmlStringValues.nodeReferenceNameDe:
                                reference.NameDE = child.InnerText;
                                break;
                            case xmlStringValues.nodeReferenceNameEn:
                                reference.NameEN = child.InnerText;
                                break;
                            default:
                                break;
                        }
                    }


                    if (!dictionary.ContainsKey(reference.ID))
                    {
                        dictionary.Add(reference.ID, reference);
                    }
                }
            }
        }
                
        #endregion

        #region enumTypes zu String

        /// <summary>
        /// converst bad cc type to string
        /// </summary>
        /// <param name="types"></param>
        /// <param name="lang"></param>
        /// <returns></returns>
        public static string BadCCTypeToString(BadCCTypes types, Languages lang)
        {
            string type = "";
            switch (types)
	            {
		            case BadCCTypes.crash:
                        if (lang == Languages.de)
                            type = "Absturz";
                        else
                            type = "Crash";
                     break;
                    case BadCCTypes.txtcerror:
                     if (lang == Languages.de)
                         type = "TXTC-Fehler";
                     else
                         type = "TXTC error";
                     break;
                    case BadCCTypes.textureerror:
                     if (lang == Languages.de)
                         type = "Textur- oder Mapping-Fehler";
                     else
                         type = "Texture or mapping error";
                     break;
                    case BadCCTypes.other:
                     if (lang == Languages.de)
                         type = "Sonstige";
                     else
                         type = "Other";
                     break;
                    default:
                     break;
	            }

	     return type;
        }

        /// <summary>
        /// converts contenttype to string (english or german)
        /// </summary>
        /// <param name="types"></param>
        /// <param name="lang"></param>
        /// <returns></returns>
        public static string ContentTypeToString(ContentTypes types, Languages lang)
        {
            String type = "";

            switch (types)
            {
                case ContentTypes.sim:
                    type = "Sim";
                    break;
                case ContentTypes.household:
                    if (lang == Languages.de)
                        type = "Haushalt";
                    else
                        type = "Household";
                    break;
                case ContentTypes.lot:
                    if (lang == Languages.de)
                        type = "Grundstück";
                    else
                        type = "Lot";
                    break;
                case ContentTypes.world:
                    if (lang == Languages.de)
                        type = "Welt";
                    else
                        type = "World";
                    break;
                case ContentTypes.preset:
                    if (lang == Languages.de)
                        type = "Farbauswahl";
                    else
                        type = "Preset";
                    break;
                case ContentTypes.haircolorinfo:
                    if (lang == Languages.de)
                        type = "Haarfarbe";
                    else
                        type = "Hair Color";
                    break;
                case ContentTypes.coatset:
                    if (lang == Languages.de)
                        type = "Tierfarbe";
                    else
                        type = "Pet Color";
                    break;
                case ContentTypes.pattern:
                    if (lang == Languages.de)
                        type = "Muster";
                    else
                        type = "Pattern";
                    break;
                case ContentTypes.cascolorinfo:
                    if (lang == Languages.de)
                        type = "Muster Farbauswahl";
                    else
                        type = "Pattern Preset";
                    break;
                case ContentTypes.CASPart:
                    if (lang == Languages.de)
                        type = "CAS Element";
                    else
                        type = "CAS Part";
                    break;
                case ContentTypes.gameobject:
                    if (lang == Languages.de)
                        type = "Objekt";
                    else
                        type = "Object";
                    break;
                case ContentTypes.unknown:
                    if (lang == Languages.de)
                        type = "Unbekannt";
                    else
                        type = "Unknown";
                    break;
                default:
                    break;
            }

            return type;
        }

        /// <summary>
        /// gets content type from a string
        /// </summary>
        /// <param name="xmlAttrValue">enum ContentType</param>
        /// <returns></returns>
        public static ContentTypes StringToContentType(string xmlAttrValue)
        {
            ContentTypes contentType = ContentTypes.unknown;

            switch (xmlAttrValue)
            {
                case xmlStringValues.attrContentTypeValSim:
                    contentType = ContentTypes.sim;
                    break;
                case xmlStringValues.attrContentTypeValHousehold:
                    contentType = ContentTypes.household;
                    break;
                case xmlStringValues.attrContentTypeValLot:
                    contentType = ContentTypes.lot;
                    break;
                case xmlStringValues.attrContentTypeValWorld:
                    contentType = ContentTypes.world;
                    break;
                case xmlStringValues.attrContentTypeValPreset:
                    contentType = ContentTypes.preset;
                    break;
                case xmlStringValues.attrContentTypeValHaircolorinfo:
                    contentType = ContentTypes.haircolorinfo;
                    break;
                case xmlStringValues.attrContentTypeValCoatset:
                    contentType = ContentTypes.coatset;
                    break;
                case xmlStringValues.attrContentTypeValPattern:
                    contentType = ContentTypes.pattern;
                    break;
                case xmlStringValues.attrContentTypeValCascolorinfo:
                    contentType = ContentTypes.cascolorinfo;
                    break;
                case xmlStringValues.attrContentTypeValCasPart:
                    contentType = ContentTypes.CASPart;
                    break;
                case xmlStringValues.attrContentTypeValObject:
                    contentType = ContentTypes.gameobject;
                    break;
                default:
                    break;
            }
            return contentType;
        }

        #endregion

        #region clear info

        /// <summary>
        /// clears all information about badCC
        /// </summary>
        public void clearBadCCInformation()
        {
            _dictBadCC.Clear();            
        }

        /// <summary>
        /// clears all information about knownCC
        /// </summary>
        public void clearKnownCCInformation()
        {
            _dictKnownPackages.Clear();
        }
        #endregion


        #endregion
    }
}
